<div class="form-group">

    <div class="alert alert-danger">
        警告：当模板中已经添加数据后切换自定义表单模板有可能导致无法使用！
    </div>

    <div class="form-group">
        <label class="col-xs-12 col-sm-3 col-md-2 control-label">自定义表单形式</label>

        {ife 'goods' $item}
        <div class="col-sm-9 col-xs-12">
            <label class="radio radio-inline" style="float: left;">
                <input type="radio" value="0" name="diyformtype" {if empty($item['diyformtype'])}checked="true"{/if}> 关闭
            </label>

            <label class="radio radio-inline" style="float: left;">
                <input type="radio" value="2" name="diyformtype" {if $item['diyformtype'] == 2}checked="true"{/if}> 自定义
            </label>

            <label class="radio radio-inline" style="float: left;">
                <input type="radio" value="1" name="diyformtype" {if $item['diyformtype'] == 1}checked="true"{/if}> 使用模板
            </label>

            <select id="user_diyform" name="diyformid" class="form-control" style="width:auto; float: left;margin-left:10px;">
                <option value="{$value['id']}" {if $item['diyformid']==0}selected{/if}>--选择自定义表单--</option>
                {loop $form_list $key $value}
                <option value="{$value['id']}" {if $item['diyformid']==$value['id']}selected{/if}>{$value['title']}</option>
                {/loop}
            </select>

        </div>

        <div class="diyform-group" {if $item['diyformtype'] != 2}style="display:none;"{/if}>

            <label class="col-xs-12 col-sm-3 col-md-2 control-label diyform-group">保存为表单模板</label>
            <div class="col-sm-9 col-xs-12 diyform-group">
                <label class="radio radio-inline" style="float: left;">
                    <input type="radio" value="0" name="diysave" {if empty($item['diysave'])}checked="true"{/if}> 不保存
                </label>

                <label class="radio radio-inline" style="float: left;">
                    <input type="radio" value="1" name="diysave" {if $item['diysave'] == 1}checked="true"{/if}> 保存
                </label>
                <label class="radio radio-inline" style="float: left;cursor:default;">
                {if !empty($diyforminfo)}
                    (该表单已经保存为 <font style="color: red;">{$diyforminfo["title"]}</font> 的模板)
                {/if}
                </label>
            </div>

        </div>

        {else}
        <div class='form-control-static'>
            {if empty($item['diyformtype'])}
            关闭
            {else}
            开启
            {loop $form_list $key $value}
            {if $item['diyformid']==$value['id']}{$value['title']}{/if}
            {/loop}
            {/if}
        </div>

        {/if} 

<!--        <label class="col-xs-12 col-sm-3 col-md-2 control-label">订单模式</label>

        <div class="col-sm-9 col-xs-12">
            <label class="radio radio-inline" style="float: left;">
                <input type="radio" value="0" name="diymode" {if empty($item['diymode'])}checked{/if}> 系统默认
            </label>

            <label class="radio radio-inline" style="float: left;">
                <input type="radio" value="1" name="diymode" {if $item['diymode'] == 1}checked{/if}> 点击立即购买时填写
            </label>
            <label class="radio radio-inline" style="float: left;">
                <input type="radio" value="2" name="diymode" {if $item['diymode'] == 2}checked{/if}> 确认订单时填写
            </label>

        </div>-->


    </div>

    <div class="diyform-group" style="margin:0 25px;" {if $item['diyformtype'] != 2}style="display:none;"{/if}>
    {template 'diyform/temp/tpl/data'}
    </div>

</div>

{template 'diyform/temp/tpl/script'}

<script>
    $(function () {
        $(':radio[name=diyformtype]').click(function () {
            window.type = $("input[name='diyformtype']:checked").val();

            if(window.type=='2'){
                $('.diyform-group').show();
            } else {
                $('.diyform-group').hide();
            }
        })
    })
</script>
